<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        span{
            display: inline-block;
            height: 20px;
            width: 20px;
            border-radius: 10px;
            color: white;
            line-height: 20px;
        }
        
        .dui{
            background-color: green;
            text-align: center;
            
        }
        .cuo{
            background-color: red;
            text-align: center;
        }
        input{
            height: 20px;
        }
        label{
            vertical-align: bottom;
        }
    </style>
</head>
<body>
    <span class="dui">✔</span>
    <span class="cuo">✖</span>
    <br>
    密码：<input type="password" id = "pass"><br>
    确认：<input type="password" id = "repass" onkeyup="change()"><label id = "label"></label>
    <script>
        function change(){
            console.log("出发改变事件");
            
            var pass = document.getElementById("pass")
            var repass = document.getElementById("repass")
            if(pass.value == repass.value){
                document.getElementById("label").innerHTML = "<span class='dui'>✔</span>";
            }else{
                document.getElementById("label").innerHTML = "<span class='cuo'>✖</span>";
            }
        }
    </script>
</body>
</html>